﻿using IOC.Desgin;
using ORM.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ORM.Base
{
    public class RecordIntercept : IIntercept
    {
        public void After(object @object, string MethodName, object Result, DateTime Start, DateTime End)
        {
            int TotalTime = Convert.ToInt32((End - Start).TotalMilliseconds);
            Record reccord = (Record)@object;
            if (reccord.TraceSQL)
            {
                reccord.Trace(TotalTime);
            }

            if (ConfigUtil.IsTraceOvertTimeSQL())
            {
                if (TotalTime > ConfigUtil.GetTraceOverTimeLimit())
                {
                    reccord.TraceOverTime(TotalTime);
                }

            }
        }

        public void Before(object @object, string MethodName, object[] Parameters)
        {
            
        }
    }
}
